// pages/make/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    A:"",
    B:"",
    C:"",
    D:"",
    get_question:[],
    title:""
  },
  title(e){
    console.log(e.detail.value)
    this.setData({
      title:e.detail.value
    })
  },
  A(e){
    console.log(e.detail.value)
    this.setData({
      A:e.detail.value
    })
  },
  B(e){
    console.log(e.detail.value)
    this.setData({
      B:e.detail.value
    })
  },
  C(e){
    console.log(e.detail.value)
    this.setData({
      C:e.detail.value
    })
  },
  D(e){
    console.log(e.detail.value)
    this.setData({
      D:e.detail.value
    })
  },
  E(e){
    console.log(e.detail.value)
    this.setData({
      D:e.detail.value
    })
  },
  F(e){
    console.log(e.detail.value)
    this.setData({
      D:e.detail.value
    })
  },
  check(){
    wx.navigateTo({
      url: '../make/review',
    })
  },
  next(){
    if(this.data.questionId<=10){
    var get_question=wx.getStorageSync('question')
    var options=[{"code":"A","option":this.data.A},{"code":"B","option":this.data.B},{"code":"C","option":this.data.C},{"code":"D","option":this.data.D}]
    var neirong=[{"questionId":this.data.questionId,"title":this.data.title,"options":options}]
    if(get_question.length==0){
      wx.setStorageSync('question', this.data.get_question.concat(neirong))
    } if(get_question.length>=1){
      var nr= get_question.concat(neirong)
      wx.setStorageSync('question', nr)
    }
    console.log(get_question)
    this.onLoad()
  }
  if(this.data.questionId>=10){
    wx.navigateTo({
      url: '../make/review',
    })
  }
  },
  // [{"regular":[{"questionId":1,"title":"1. 你是否因为没有带口罩出门而感到焦躁、担心和不安（在过去的一个月）？",
  // "options":[{"code":"A","option":"一点也没有"},{"code":"B","option":"只有一点点"},{"code":"C","option":"有些，但不严重"},{"code":"D","option":"是的，非常严重"}]},{

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var get_question=wx.getStorageSync('question')
   this.setData({
     questionId:get_question.length+1,
     A:"",
     B:"",
     C:"",
     D:"",
     title:""
   })
   console.log(this.data.questionId)
   console.log(get_question)
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})